package cn.edu.lingnan.tourism.mapper;

import cn.edu.lingnan.tourism.pojo.Favorite;
import cn.edu.lingnan.tourism.pojo.Route;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.annotation.KeySql;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;
import java.util.Map;

public interface FavoriteMapper extends Mapper<Favorite> {
    //查询收藏夹中的路线
    @Select("SELECT * from tab_route where rid in(SELECT rid FROM tab_favorite where uid=#{uid})")
    public List<Route> selectFavoriteRouteByUid(Integer rid);

   @Select("SELECT * FROM tab_route WHERE rid in(SELECT  result.rid FROM(SELECT rid, COUNT(uid) AS uid_count FROM tab_favorite GROUP BY rid ORDER BY uid_count DESC LIMIT 4)as result)")
    public List<Route> selectFavoriteRouteCount();
}
